﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataConcept.Entities;

namespace DataConcept.Business
{
    public class bl_Concept
    {
        da_ConceptEntities db = new da_ConceptEntities();

        public Guid Create(string value, string key, byte? status)
        {
            if (!status.HasValue) status = 0;

            var conceptId = Guid.NewGuid();
            var result = (int)db.da_Concept_New(
                conceptId,
                value,
                key,
                status).Single();

            if (result > 0)
                return conceptId;
            else
                return Guid.Empty;
        }
        public int Update(Guid conceptId, string value, string key, byte status)
        {
            var result = (int)db.da_Concept_Update(
                conceptId,
                value,
                key,
                status).Single();

            return result;
        }
        public int Delete(Guid conceptId)
        {
            var result = (int)db.da_Concept_Delete(
                conceptId).Single();

            return result;
        }

        public da_Concept GetById(Guid conceptId)
        {
            var result = db.da_Concept_GetbyId(conceptId).ToList();

            if (result.Count > 0)
                return result.First();
            else
                return null;
        }
        public List<da_Concept> GetAll()
        {
            var result = db.da_Concept.ToList();

            return result;
        }
    }
}
